package apis

import (
	"gitee.com/byx_darwin/ncloud-go/core"
	"gitee.com/byx_darwin/ncloud-go/core/net/consts"
)

type QuerySrcConditions struct {
	StartTime  int64    `json:"start_time"`
	EndTime    int64    `json:"end_time"`
	Interval   int64    `json:"interval"`
	DomainList []string `json:"domain_list"`
}
type QuerySrcRequest struct {
	core.NCloudRequest
	QuerySrcConditions
}

func NewQuerySrcRequest(startTime, endTime, interval int64) *QuerySrcRequest {
	return &QuerySrcRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/src",
			Method: consts.MethodPost,
		},
		QuerySrcConditions: QuerySrcConditions{
			StartTime: startTime,
			EndTime:   endTime,
			Interval:  interval,
		},
	}
}
func NewQuerySrcRequestWithDomains(startTime, endTime, interval int64, list []string) *QuerySrcRequest {
	return &QuerySrcRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/src",
			Method: consts.MethodPost,
		},
		QuerySrcConditions: QuerySrcConditions{
			StartTime:  startTime,
			EndTime:    endTime,
			Interval:   interval,
			DomainList: list,
		},
	}
}

type QuerySrcResponse struct {
	Ok      bool    `json:"ok"`
	Msg     string  `json:"msg"`
	TrackID string  `json:"track_id"`
	Data    SrcData `json:"data"`
}

type SrcData struct {
	Interval   int64       `json:"interval"`
	MetricList []SrcObject `json:"metric_list,omitempty"`
}

type SrcObject struct {
	Time   uint64  `json:"time"`
	Domain string  `json:"domain"`
	Flow   uint64  `json:"flow"`
	PV     uint64  `json:"pv"`
	Qps    float64 `json:"qps"`
}
